pot:: Int -> Int -> Int
pot 0 m = 1
pot (n+1) m = m*(pot(n) m)

triomino:: Int -> (Int,Int) -> [(Int,Int)]
triomino 0 _ = []
triomino 1 (x,y)
     -- primer cuadrante
     | (x == 0) && (y == 0) = [(1,0)] ++ [(1,1)] ++ [(0,1)]  
     -- segundo cuadrante	    
     | (x == 0) && (y == 1) = [(0,0)] ++ [(1,1)] ++ [(1,0)]
     -- tercer cuadrante             
     | (x == 1) && (y == 0) = [(0,0)] ++ [(1,1)] ++ [(0,1)]
     -- cuarto cuadrante
     | (x == 1) && (y == 1) = [(1,0)] ++ [(0,0)] ++ [(0,1)]	
triomino (n+1) (x,y)
	-- primer cuadrante
	| (x <= pot n 2) && (y >= pot n 2) = triomino n (x,y-(pot n 2)) ++ a ++ b ++ c ++ [(pot n 2,(pot n 2)-1)] ++ [(pot n 2,pot n 2)] ++ 
										 [((pot n 2)-1,(pot n 2)-1)]  
	-- segundo cuadrante	    
	| (x <= pot n 2) && (y <= pot n 2) = triomino n (x,y) ++ d ++ e ++ f ++ [(pot n 2,(pot n 2)-1)] ++ [(pot n 2,pot n 2)] ++ [((pot n 2)-1,pot n 2)]
	-- tercer cuadrante
	| (x >= pot n 2) && (y <= pot n 2) = triomino n (x-(pot n 2),y) ++ g ++ h ++ i ++ [((pot n 2)-1,(pot n 2)-1)] ++ [(pot n 2,pot n 2)] ++ [((pot n 2)-1,pot n 2)]
	-- cuarto cuadrante
	|(x >= pot n 2) && (y >= pot n 2) = triomino n (x-(pot n 2),y-(pot n 2)) ++ j ++ k ++ l ++
									  [((pot n 2)-1,(pot n 2)-1)] ++ [(pot n 2,pot n 2)] ++ [((pot n 2)-1,pot n 2)] -- *************
  		where
			a' = triomino n (0,0)
  			b' = triomino n ((pot n 2)-1,(pot n 2)-1) 
  			c' = triomino n (0,(pot n 2)-1)
  			a  = map (offset (pot n 2) (pot n 2)) a' 
  			b  = map (offset 0 0) b'
  			c  = map (offset (pot n 2) 0) c' -- *********************
			d' = triomino n ((pot n 2)-1,0)
			e' = triomino n (0,(pot n 2)-1) 
  			f' = triomino n (0,0)
  			d  = map (offset 0 (pot n 2)) d'
  			e  = map (offset (pot n 2) 0) e'
  			f  = map (offset (pot n 2) (pot n 2)) f' -- *********************
			g' = triomino n ((pot n 2)-1,(pot n 2)-1) 
			h' = triomino n (0,0) 
  			i' = triomino n ((pot n 2)-1,0)
  			g  = map (offset 0 0) g'
  			h  = map (offset (pot n 2) (pot n 2)) h'
  			i  = map (offset 0 (pot n 2)) i' -- *********************
			j' = triomino n (0,(pot n 2)-1)
			k' = triomino n ((pot n 2)-1,0) 
  			l' = triomino n ((pot n 2)-1,(pot n 2)-1)
  			j  = map (offset (pot n 2) 0) j'
  			k  = map (offset 0 (pot n 2)) k'
  			l  = map (offset 0 0) l'

offset:: Int -> Int -> (Int,Int) -> (Int,Int) 
offset x y (x1,y1) = (x1+x,y1+y)











